/**************************************************************************************************
V A R S
**************************************************************************************************/

// Invalid XML attributes that will always be ditched at the first chance
var invalid_xml_attr = new Array("contains", "indexOf", "without", "flatten", "compact", "last", "first", "_reverse", "clear", "_each", "entries", "member", "select", "find", "map", "inspect", "zip", "toArray", "sortBy", "reject", "pluck", "partition", "min", "max", "invoke", "inject", "include", "grep", "findAll", "detect", "collect", "any", "all", "each");


/**************************************************************************************************
I N T E R F A C E   H A N D L E R S
**************************************************************************************************/

/**
 * selectInputXML selects an input file for loading
 *
 * @param file URL is the URL to load
 * @param tree_box is the tree box to load it into
*/
function selectInputXML(select_obj, tree_box) {
	loadTBXML(select_obj, tree_box);
}

/**
 * updateButtons() updates the button modes
 *
 * @param tree_box is the tree box
*/
function updateButtons(tree_box) {
	
	
	
	// Reset the checkbox
	try {
		document.getElementById("listsort").checked = false;
	} catch (e) { }
	
	switch (treeboxes[tree_box].display_mode) {
		case "list":
		
			// Set Button statuses
			try {
				document.getElementById("ttlbutton").disabled = true;
				document.getElementById("lttbutton").disabled = false;
				document.getElementById("listsort").disabled = false;
			} catch (e) { }
			
			break;
			
		case "tree":
		
			// Set Button statuses
			try {
				document.getElementById("ttlbutton").disabled = false;
				document.getElementById("lttbutton").disabled = true;
				document.getElementById("listsort").disabled = true;
			} catch (e) { }
			
			break;
		
		default:
		
			// Set Button statuses
			try {
				document.getElementById("ttlbutton").disabled = true;
				document.getElementById("lttbutton").disabled = true;
				document.getElementById("listsort").disabled = true;
			} catch (e) { }
			
			break;
	}
}


/**
 * findInArray() searches an array for a particular value
 *
 * @param array is the array
 * @param find is the string to find
 *
 * @return the index of the found string, or -1 if not found
*/
function findInArray(array, find) {
	for (var i in array) {
		if (("" + array[i]).toLowerCase() == ("" + find).toLowerCase()) {
			return i;
		}
	}
	
	// Fail
	return -1;
}